<template>
    <div class="app-container">
      <el-form
        :model="queryParams"
        ref="queryRef"
        :inline="true"
        v-show="showSearch"
        label-width="68px"
      >
        <el-form-item
          label="页面名称"
          prop="pageName"
          v-hasPermi="['business:hairTeacherSubscribe:queryShopName']"
        >
          <el-input
            v-model="queryParams.pageName"
            placeholder="请输入页面名称"
            clearable
            @keyup.enter="handleQuery"
          />
        </el-form-item>
        <!-- <el-form-item label="选择门店" prop="shopId">
          <el-select v-model="queryParams.shopId" value-key="id" filterable>
            <el-option
              v-for="item in hairFixShopList"
              :key="item.id"
              :label="item.bokaName"
              :value="item.id"
          /></el-select>
        </el-form-item> -->
        <el-form-item
          label="企微信ID"
          prop="userId"
          v-hasPermi="['business:hairTeacherSubscribe:queryShopName']"
        >
          <el-input
            v-model="queryParams.userId"
            placeholder="请输入企微信ID"
            clearable
            @keyup.enter="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="Search" @click="handleQuery"
            >搜索</el-button
          >
          <el-button icon="Refresh" @click="resetQuery">重置</el-button>
          <el-button
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['business:hairTriggerEvent:export']"
          >导出</el-button
        >
        </el-form-item>
      </el-form>
      <el-table
        v-loading="loading"
        :data="userBehaviorList"
        @selection-change="handleSelectionChange"
        border
      >
        <el-table-column label="企微用户id" align="center" prop="userId" />
        <el-table-column label="企微昵称" align="center" prop="userNick" />
        <el-table-column label="页面地址" align="center" prop="pagePath" />
        <el-table-column label="页面名称" align="center" prop="pageName" />
        <el-table-column label="平台" align="center" prop="ispc" />
        <el-table-column label="网络状态" align="center" prop="networkType" />
        <el-table-column label="开始时间" align="center" prop="startTime" />
        <el-table-column label="结束时间" align="center" prop="endTime" />
        <el-table-column label="加载时长" align="center" prop="requestDuration" >
            <template #default="scope">
            {{ scope.row.requestDuration/1000 }}s
            </template>
        </el-table-column>
      </el-table>
  
      <pagination
        v-show="total > 0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </template>
  
  <script setup name="HairFixShop">
  import {batchUpdatePageName, pageNotworkListApi} from "@/api/business/userBehavior";
  import { parseConvertTime } from "@/utils/ruoyi";
  import ImageUploads from "@/components/ImageUploads/index.vue";
  const { proxy } = getCurrentInstance();
  const buttonLoading = ref(false);
  const userBehaviorList = ref([]);
  const matterButtonList = ref([]);
  const openButtonData = ref(false);
  const pageOpen = ref(false);
  const loading = ref(true);
  const showSearch = ref(true);
  const ids = ref([]);
  const total = ref(0);
  
  const data = reactive({
    form: {},
    queryParams: {
      pageNum: 1,
      pageSize: 10,
      pageName:'',
      shopId: undefined,
    },
  });
  const shopId = ref({})
  const { queryParams, form } = toRefs(data);
  const hairFixShopList = ref([])
  

  /** 查询用户访问数据列表 */
  function getList() {
    loading.value = true;
    pageNotworkListApi(queryParams.value).then((response) => {
      userBehaviorList.value = response.rows;
      total.value = response.total;
      loading.value = false;
    });
  }
  /** 导出按钮操作 */
  function handleExport() {
    proxy.download(
      "/business/pageNotwork/export",
      {
        ...queryParams.value,
      },
      `hairTriggerEvent_${new Date().getTime()}.xlsx`
    );
  }
  /** 搜索按钮操作 */
  function handleQuery() {
    queryParams.value.pageNum = 1;
    console.log(queryParams.value)
    getList();
  }
  // 取消按钮
  function cancel() {
    pageOpen.value = false;
    reset();
  }
  /** 重置按钮操作 */
  function resetQuery() {
    proxy.resetForm("queryRef");
    queryParams.value.valueDate = null;
    queryParams.value.menu = null;
  
    queryParams.value.router = null;
  
    handleQuery();
  }
  
  function updatePageName(){
    pageOpen.value = true;
  }
  
  function submitUpdatePage(){
    batchUpdatePageName(form.value).then(response => {
      proxy.$modal.msgSuccess("修改成功");
      pageOpen.value = false;
      form.value = {}
      getList();
    }).finally(() => {
      buttonLoading.value = false;
    });
  }
  
  // 点击查看按钮详情
  function handleDetials(row) {
    loading.value = true;
    let query = {
      userId: row.userId,
      valueDate: row.valueDate,
    };
    userBehaviorListDetialsApi(query).then((response) => {
      openButtonData.value = true;
      console.log(response.rows);
      matterButtonList.value = response.rows;
      loading.value = false;
    });
  }
  
  getList();
  </script>
  <style>
  .info-content {
    border: 2rpx solid #000000;
    padding: 10rpx;
  }
  </style>
  